package book;

import javax.naming.Name;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

public class Mybook {

    private String name;
    private String press;
    private String author;
    private String bookISBN;
    public Mybook(String name, String press, String author, String bookISBN) {
        this.name = name;
        this.press = press;
        this.author = author;
        this.bookISBN = bookISBN;
    }
    public Mybook(String [] args){
        this.name = args[0];
        this.author =  args[1];
        this.press = args[2];
        this.bookISBN = args[3];
    }

    public String getName() {return name;}
    public void setName(String name) {this.name = name;}

    public String getPress() {return press;}

    public void setPress(String press) {this.press = press;
    }

    public String getAuthor() {return author;}

    public void setAuthor(String author) {this.author = author;}

    public String getBookISBN() {return bookISBN;}

    public void setBookISBN(String bookISBN) {
        this.bookISBN = bookISBN;
    }

    public Mybook() {
    }


    public void inputData(Map<String, Mybook> map1){

        System.out.println("/*     请输入录入图书的数量    */");
        Scanner scanner = new Scanner(System.in);
        int num =scanner.nextInt();
        for (int i = 0;i < num;i++)
        {
            Mybook mybook2 = new Mybook();
            Scanner s2 = new Scanner(System.in);
            System.out.println("/*      请输入书名       */");
            mybook2.setName(s2.next());
            System.out.println("/*      请输入出版社      */");
            mybook2.setPress(s2.next());
            System.out.println("/*      请输入作者        */");
            mybook2.setAuthor(s2.next());
            System.out.println("/*      请输入ISBN       */");
            mybook2.setBookISBN(s2.next());
            map1.put(mybook2.getName(),mybook2);
        }
//        public void inputData2(Map<String, Mybook> map2){
//
//        }
    }
    //    public String pri(HashMap<String,String> books){
//        System.out.println("书名:"+books.get(name));
//        System.out.println("书名:"+books.get(press) );
//        System.out.println("书名:"+books.get(author) );
//        System.out.println("书名:"+books.get(bookISBN) );
//        String information = ("书名"+books.get(name));
//        return information;
//    }
    public void print(Map<String, Mybook> map){
//    int num = map.size();
//    for (int i = 0;i<num;i++){
//       System.out.println();
//    }
        Collection<Mybook>coll = map.values();
        Iterator<Mybook>iterator = coll.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next().getBookISBN());
            System.out.println(iterator.next().getName());
        }
    }

//    public void deleteName(){
//        Scanner scanner = new Scanner(System.in);
//        System.out.println("/*      请输入要删除的书名       */");
//        name = scanner.next();//输入你要找的书名
//        ConcurrentHashMap<String,String> entries = new ConcurrentHashMap<>(books);
//        for (Map.Entry<String,String> entry:entries.entrySet()){
//            if (name.equals(books.get(scanner.hasNext()))){
//                books.remove(entry.getKey());
//                System.out.println("删除成功");
//                break;
//            }else{
//                System.out.println("删除失败");
//            }
//        }
//        System.out.println();
//    }

}